import { defineStore } from 'pinia'

// 全局状态存储
export const useGlobalStore = defineStore('global', {
  state: () => ({
    // 全局加载状态
    loading: false,
    
    // 全局提示信息
    message: {
      type: '',
      content: ''
    }
  }),
  
  actions: {
    // 显示加载状态
    setLoading(status: boolean) {
      this.loading = status
    },
    
    // 显示提示信息
    showMessage(type: string, content: string) {
      this.message = {
        type,
        content
      }
      
      // 3秒后自动清除消息
      setTimeout(() => {
        this.message = {
          type: '',
          content: ''
        }
      }, 3000)
    }
  }
})